using UnityEngine;

public class Spawner : MonoBehaviour
{
    public GameObject enemy1;
    public float enemy1SpawnInterval1 = 1;
    public GameObject enemy2;
    public float enemy1SpawnInterval2 = 2;
    public GameObject enemy3;
    public float enemy1SpawnInterval3 = 5;

    public GameObject award1;
    public float award1SpawnInterval1 = 8;
    public GameObject award2;
    public float award2SpawnInterval2 = 15;

    // Start is called before the first frame update
    void Start()
    {
        //  延迟1秒
        InvokeRepeating("SpawnEnemy1", 1, enemy1SpawnInterval1);
        InvokeRepeating("SpawnEnemy2", 1, enemy1SpawnInterval2);
        InvokeRepeating("SpawnEnemy3", 1, enemy1SpawnInterval3);

        InvokeRepeating("SpawnAward1", 1, enemy1SpawnInterval2);
        InvokeRepeating("SpawnAward2", 1, enemy1SpawnInterval3);
    }

    // Update is called once per frame
    void Update()
    {
    }

    public void SpawnEnemy1()
    {
        // y 用当前spawner的y x随机
        Instantiate(enemy1,
            new Vector3(Random.Range(-1.98f, 1.98f),
                transform.position.y,
                transform.position.z),
            transform.rotation);
    }

    public void SpawnEnemy2()
    {
        // y 用当前spawner的y x随机
        Instantiate(enemy2,
            new Vector3(Random.Range(-1.95f, 1.95f),
                transform.position.y,
                transform.position.z),
            transform.rotation);
    }

    public void SpawnEnemy3()
    {
        // y 用当前spawner的y x随机
        Instantiate(enemy3,
            new Vector3(Random.Range(-1.46f, 1.46f),
                transform.position.y,
                transform.position.z),
            transform.rotation);
    }

    public void SpawnAward1()
    {
        // y 用当前spawner的y x随机
        Instantiate(award1,
            new Vector3(Random.Range(-1.96f, 1.96f),
                transform.position.y,
                transform.position.z),
            transform.rotation);
    }

    public void SpawnAward2()
    {
        // y 用当前spawner的y x随机
        Instantiate(award2,
            new Vector3(Random.Range(-1.96f, 1.96f),
                transform.position.y,
                transform.position.z),
            transform.rotation);
    }
}